package com.example.unisys.controller;

import com.example.unisys.common.Response;
import com.example.unisys.cache.RecentCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/apis/v1/redis/courses")
public class RedisController {
    @Autowired
    private RecentCourseService recentCourseService;

    @GetMapping("/set")
    public Response setCourses(@RequestParam(value = "exam_id") String exam_id, @RequestParam(value = "data") String data) {
        return recentCourseService.setCourses(exam_id, data);
    }

    @GetMapping("/get")
    public Response getCourses(@RequestParam(value = "exam_id") String exam_id) {
        return recentCourseService.getCourses(exam_id);
    }
}
